<template>
  <div>
    <!-- 页面头部 -->
    <section class="bg-gradient-to-br from-primary-600 to-primary-800 text-white section-padding">
      <div class="container-custom">
        <div class="max-w-3xl mx-auto text-center">
          <h1 class="text-4xl md:text-5xl font-bold mb-6">联系我们</h1>
          <p class="text-xl text-primary-100 leading-relaxed">
            我们期待与您合作，为您的企业提供专业的数字化解决方案。
          </p>
        </div>
      </div>
    </section>

    <!-- 联系信息 -->
    <section class="section-padding">
      <div class="container-custom">
        <div class="grid grid-cols-1 lg:grid-cols-2 gap-12">
          <!-- 联系表单 -->
          <div class="bg-white rounded-2xl shadow-xl p-8">
            <h2 class="text-2xl font-bold text-gray-900 mb-6">发送消息</h2>
            
            <form @submit.prevent="submitForm" class="space-y-6">
              <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                <div>
                  <label for="name" class="block text-sm font-medium text-gray-700 mb-2">姓名 *</label>
                  <input
                    id="name"
                    v-model="form.name"
                    type="text"
                    required
                    class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
                    placeholder="请输入您的姓名"
                  />
                </div>
                <div>
                  <label for="phone" class="block text-sm font-medium text-gray-700 mb-2">电话 *</label>
                  <input
                    id="phone"
                    v-model="form.phone"
                    type="tel"
                    required
                    class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
                    placeholder="请输入您的电话"
                  />
                </div>
              </div>
              
              <div>
                <label for="email" class="block text-sm font-medium text-gray-700 mb-2">邮箱</label>
                <input
                  id="email"
                  v-model="form.email"
                  type="email"
                  class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
                  placeholder="请输入您的邮箱"
                />
              </div>
              
              <div>
                <label for="company" class="block text-sm font-medium text-gray-700 mb-2">公司名称</label>
                <input
                  id="company"
                  v-model="form.company"
                  type="text"
                  class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
                  placeholder="请输入您的公司名称"
                />
              </div>
              
              <div>
                <label for="service" class="block text-sm font-medium text-gray-700 mb-2">感兴趣的服务</label>
                <select
                  id="service"
                  v-model="form.service"
                  class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
                >
                  <option value="">请选择服务类型</option>
                  <option value="软件开发">软件开发</option>
                  <option value="技术咨询">技术咨询</option>
                  <option value="系统集成">系统集成</option>
                  <option value="运维支持">运维支持</option>
                  <option value="数据分析">数据分析</option>
                  <option value="云服务">云服务</option>
                  <option value="其他">其他</option>
                </select>
              </div>
              
              <div>
                <label for="message" class="block text-sm font-medium text-gray-700 mb-2">需求描述 *</label>
                <textarea
                  id="message"
                  v-model="form.message"
                  rows="4"
                  required
                  class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
                  placeholder="请详细描述您的需求"
                ></textarea>
              </div>
              
              <button
                type="submit"
                :disabled="isSubmitting"
                class="w-full btn-primary py-4 text-lg disabled:opacity-50 disabled:cursor-not-allowed"
              >
                {{ isSubmitting ? '提交中...' : '发送消息' }}
              </button>
            </form>
          </div>
          
          <!-- 联系信息 -->
          <div class="space-y-8">
            <div>
              <h2 class="text-2xl font-bold text-gray-900 mb-6">联系信息</h2>
              
              <div class="space-y-6">
                <div class="flex items-start space-x-4">
                  <div class="w-12 h-12 bg-primary-100 rounded-lg flex items-center justify-center flex-shrink-0">
                    <svg class="w-6 h-6 text-primary-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />
                    </svg>
                  </div>
                  <div>
                    <h3 class="text-lg font-semibold text-gray-900 mb-1">电话</h3>
                    <p class="text-gray-600">+86 400-123-4567</p>
                    <p class="text-gray-600">+86 010-1234-5678</p>
                  </div>
                </div>
                
                <div class="flex items-start space-x-4">
                  <div class="w-12 h-12 bg-primary-100 rounded-lg flex items-center justify-center flex-shrink-0">
                    <svg class="w-6 h-6 text-primary-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 4.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
                    </svg>
                  </div>
                  <div>
                    <h3 class="text-lg font-semibold text-gray-900 mb-1">邮箱</h3>
                    <p class="text-gray-600">contact@lz-enterprise.com</p>
                    <p class="text-gray-600">support@lz-enterprise.com</p>
                  </div>
                </div>
                
                <div class="flex items-start space-x-4">
                  <div class="w-12 h-12 bg-primary-100 rounded-lg flex items-center justify-center flex-shrink-0">
                    <svg class="w-6 h-6 text-primary-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" />
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" />
                    </svg>
                  </div>
                  <div>
                    <h3 class="text-lg font-semibold text-gray-900 mb-1">地址</h3>
                    <p class="text-gray-600">北京市朝阳区xxx大厦</p>
                    <p class="text-gray-600">A座15层1501室</p>
                  </div>
                </div>
                
                <div class="flex items-start space-x-4">
                  <div class="w-12 h-12 bg-primary-100 rounded-lg flex items-center justify-center flex-shrink-0">
                    <svg class="w-6 h-6 text-primary-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                      <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
                    </svg>
                  </div>
                  <div>
                    <h3 class="text-lg font-semibold text-gray-900 mb-1">工作时间</h3>
                    <p class="text-gray-600">周一至周五：9:00 - 18:00</p>
                    <p class="text-gray-600">周六：9:00 - 12:00</p>
                  </div>
                </div>
              </div>
            </div>
            
            <!-- 地图占位 -->
            <div class="bg-gray-100 rounded-xl h-64 flex items-center justify-center">
              <div class="text-center text-gray-500">
                <svg class="w-16 h-16 mx-auto mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" />
                  <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" />
                </svg>
                <p class="text-lg font-medium">公司位置</p>
                <p class="text-sm">北京市朝阳区xxx大厦</p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- FAQ -->
    <section class="section-padding bg-gray-50">
      <div class="container-custom">
        <div class="text-center mb-16">
          <h2 class="text-3xl font-bold text-gray-900 mb-4">常见问题</h2>
          <p class="text-lg text-gray-600 max-w-2xl mx-auto">
            以下是一些客户经常询问的问题，如果您有其他问题，请随时联系我们。
          </p>
        </div>
        
        <div class="max-w-3xl mx-auto space-y-4">
          <div 
            v-for="(faq, index) in faqs" 
            :key="faq.id"
            class="bg-white rounded-lg shadow-sm"
          >
            <button
              @click="toggleFaq(index)"
              class="w-full px-6 py-4 text-left flex justify-between items-center hover:bg-gray-50 transition-colors duration-200"
            >
              <span class="font-medium text-gray-900">{{ faq.question }}</span>
              <svg 
                class="w-5 h-5 text-gray-500 transition-transform duration-200"
                :class="{ 'rotate-180': openFaqs.includes(index) }"
                fill="none" 
                stroke="currentColor" 
                viewBox="0 0 24 24"
              >
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
              </svg>
            </button>
            <div 
              v-if="openFaqs.includes(index)"
              class="px-6 pb-4 text-gray-600"
            >
              {{ faq.answer }}
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script setup>
// 设置页面 SEO
useHead({
  title: '联系我们',
  meta: [
    { name: 'description', content: '联系乐在企业，获取专业的数字化解决方案咨询服务。我们提供电话、邮箱、在线表单等多种联系方式。' },
    { name: 'keywords', content: '联系我们,企业咨询,技术服务,数字化解决方案,联系方式' }
  ]
})

const form = ref({
  name: '',
  phone: '',
  email: '',
  company: '',
  service: '',
  message: ''
})

const isSubmitting = ref(false)
const openFaqs = ref([])

const submitForm = async () => {
  isSubmitting.value = true
  
  try {
    // 这里可以添加实际的表单提交逻辑
    await new Promise(resolve => setTimeout(resolve, 2000)) // 模拟提交
    
    // 重置表单
    form.value = {
      name: '',
      phone: '',
      email: '',
      company: '',
      service: '',
      message: ''
    }
    
    // 显示成功消息
    alert('消息发送成功！我们会尽快与您联系。')
  } catch (error) {
    alert('发送失败，请稍后重试。')
  } finally {
    isSubmitting.value = false
  }
}

const toggleFaq = (index) => {
  const faqIndex = openFaqs.value.indexOf(index)
  if (faqIndex > -1) {
    openFaqs.value.splice(faqIndex, 1)
  } else {
    openFaqs.value.push(index)
  }
}

const faqs = [
  {
    id: 1,
    question: '你们的服务范围包括哪些？',
    answer: '我们提供软件开发、技术咨询、系统集成、运维支持、数据分析、云服务等全方位的数字化解决方案。'
  },
  {
    id: 2,
    question: '项目开发周期一般需要多长时间？',
    answer: '项目开发周期根据具体需求而定，一般小型项目1-3个月，中型项目3-6个月，大型项目6-12个月。我们会根据您的需求制定详细的项目计划。'
  },
  {
    id: 3,
    question: '如何保证项目质量？',
    answer: '我们采用严格的质量控制流程，包括需求分析、设计评审、代码审查、测试验证等环节，确保项目质量达到最高标准。'
  },
  {
    id: 4,
    question: '是否提供后期维护服务？',
    answer: '是的，我们提供7x24小时的运维支持服务，包括系统监控、故障处理、性能优化、安全防护等，确保系统稳定运行。'
  },
  {
    id: 5,
    question: '如何开始合作？',
    answer: '您可以通过电话、邮箱或在线表单联系我们，我们会安排专业的技术顾问与您沟通，了解您的具体需求，然后制定合适的解决方案。'
  }
]
</script>
